﻿using CommunityToolkit.Mvvm.Input;
using CommunityToolkit.Mvvm.Messaging;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Input;

namespace Client.ViewModels
{
    public partial class MainViewModel : ViewModelBase
    {
        public ObservableCollection<MenuItemViewModel> MenuItems { get; set; }
        public ObservableCollection<MenuItemViewModel> ChildrenMenuItems { get; set; }
        public MainViewModel()
        {
            ChildrenMenuItems = new ObservableCollection<MenuItemViewModel>()
        {
                //MenuHeader = "Introduction" -菜单名称 IsSeparator = false -是否可以使用
            new() { MenuHeader = "设备菜单1", Key = MenuKeys.MenuKeyIntroduction, IsSeparator = false},
            //new() { MenuHeader = "Controls",IsSeparator = false },
            new() { MenuHeader = "设备菜单2", Key = MenuKeys.MenuKeyClock, Status = "New" },
            new() { MenuHeader = "设备菜单3", Key = MenuKeys.MenuKeyImageViewer, Status = "New" },
        };
            MenuItems = new ObservableCollection<MenuItemViewModel>()
        {
                //MenuHeader = "Introduction" -菜单名称 IsSeparator = false -是否可以使用
            new() { MenuHeader = "设备", Key = MenuKeys.MenuKeyIntroduction, IsSeparator = false},
            //new() { MenuHeader = "Controls",IsSeparator = false },
            new() { MenuHeader = "配置", Key = MenuKeys.MenuKeyClock, Status = "New" },          
            new() { MenuHeader = "ImageViewer", Key = MenuKeys.MenuKeyImageViewer, Status = "WIP" },
        };
        }
    }
    public static class MenuKeys
    {
        public const string MenuKeyIntroduction = "Introduction";
        public const string MenuKeyBadge = "Badge";
        public const string MenuKeyBanner = "Banner";
        public const string MenuKeyButtonGroup = "ButtonGroup";
        public const string MenuKeyBreadcrumb = "Breadcrumb";
        public const string MenuKeyClassInput = "Class Input";
        public const string MenuKeyClock = "Clock";
        public const string MenuKeyDialog = "Dialog";
        public const string MenuKeyDivider = "Divider";
        public const string MenuKeyDisableContainer = "DisableContainer";
        public const string MenuKeyDrawer = "Drawer";
        public const string MenuKeyDualBadge = "DualBadge";
        public const string MenuKeyEnumSelector = "EnumSelector";
        public const string MenuKeyForm = "Form";
        public const string MenuKeyImageViewer = "ImageViewer";
        public const string MenuKeyIpBox = "IPv4Box";
        public const string MenuKeyIconButton = "IconButton";
        public const string MenuKeyKeyGestureInput = "KeyGestureInput";
        public const string MenuKeyLoading = "Loading";
        public const string MenuKeyMessageBox = "MessageBox";
        public const string MenuKeyMultiComboBox = "MultiComboBox";
        public const string MenuKeyNavMenu = "NavMenu";
        public const string MenuKeyNumberDisplayer = "NumberDisplayer";
        public const string MenuKeyNumericUpDown = "NumericUpDown";
        public const string MenuKeyNumPad = "NumPad";
        public const string MenuKeyPagination = "Pagination";
        public const string MenuKeyRangeSlider = "RangeSlider";
        public const string MenuKeyScrollToButton = "ScrollToButton";
        public const string MenuKeySelectionList = "SelectionList";
        public const string MenuKeyTagInput = "TagInput";
        public const string MenuKeySkeleton = "Skeleton";
        public const string MenuKeyTimePicker = "TimePicker";
        public const string MenuKeyTimeline = "Timeline";
        public const string MenuKeyTwoTonePathIcon = "TwoTonePathIcon";
        public const string MenuKeyThemeToggler = "ThemeToggler";
        public const string MenuKeyTreeComboBox = "TreeComboBox";
        public const string MenuKeyToolBar = "ToolBar";
        public const string MenuKeyVerificationCode = "VerificationCode";
        public const string MenuKeyTimeBox = "TimeBox";

    }

    public class MenuItemViewModel : ViewModelBase
    {
        public string MenuHeader { get; set; }
        public string MenuIconName { get; set; }
        public string Key { get; set; }
        public string Status { get; set; }

        public bool IsSeparator { get; set; }
        public ObservableCollection<MenuItemViewModel> Children { get; set; } = new();

        public ICommand ActivateCommand { get; set; }

        public MenuItemViewModel()
        {
            ActivateCommand = new RelayCommand(OnActivate);
        }

        private void OnActivate()
        {
            if (IsSeparator) return;
            WeakReferenceMessenger.Default.Send<string>(Key);
        }
    }
}
